import {request} from "../../request";
export function addCourse(data,method) {
    return request({
        url: '/course',
        method: method,
        data: data,
        headers: {
            "Content-Type":"application/json"
        },
    })
}

export function getAllCourse(page, size , username){
    return request({
        url: '/course/getAll?page=' +  page + "&" + "size=" + size + "&" + "username=" + username,
        method: 'get'
    })
}
export function getAllFile(page, size , courseId, type){
    return request({
        url: '/course/file?page=' +  page + "&" + "size=" + size + "&" + "courseId=" + courseId + "&" + "type=" + type,
        method: 'get'
    })
}


export function deleteCourse(id){
    return request({
        url: '/course/' + id,
        method: 'delete'
    })
}
export function deleteFile(id){
    return request({
        url: '/course/file/' + id,
        method: 'delete'
    })
}
export function addStudentCourse(data,method) {
    return request({
        url: '/student-course',
        method: method,
        data: data,
        headers: {
            "Content-Type":"application/json"
        },
    })
}
export function addFile(data) {
    return request({
        url: '/course/file',
        method:'post',
        data: data,
        headers: {
            "Content-Type":"application/json"
        },
    })
}
export function downloadFile(url) {
    return request({
        url: '/course/download/' + url,
        method:'post'
    })
}

export function getAllStudentCourse(page, size , username){
    return request({
        url: '/student-course/getAll?page=' +  page + "&" + "size=" + size + "&" + "username=" + username,
        method: 'get'
    })
}
export function getCourseItem(username){
    return request({
        url: '/student-course/getSelectItem?username=' + username,
        method: 'get'
    })
}
export function deleteStudentCourse(id){
    return request({
        url: '/student-course/' + id,
        method: 'delete'
    })
}

export function addProblemCourse(data,method) {
    return request({
        url: '/problem-course',
        method: method,
        data: data,
        headers: {
            "Content-Type":"application/json"
        },
    })
}

export function getAllStatistic(data,method) {
    return request({
        url: '/problem-course/getStatistic',
        method: method,
        data: data,
        headers: {
            "Content-Type":"application/json"
        },
    })
}
